package com.ymatou.iapi.godmch.testcase;

import org.json.JSONException;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymatou.iapi.godmch.parameter.createIndepMchBean;
import com.ymatou.iapi.godmch.parameter.createmchBean;
import com.ymatou.iapi.godmch.parameter.editmchBean;
import com.ymatou.iapi.godmch.parameter.getOverseasAddressConfigBean;
import com.ymatou.iapi.godmch.service.createIndepMchCall;
import com.ymatou.iapi.godmch.service.getOverseasAddressConfigCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.DGUserCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.model.godmch.mch_config;
import com.ymttest.database.model.godmch.mch_configExample;
import com.ymttest.database.sqlwapper.godmch.mch_configWapper;
/**
*获取商户是否支持海外地址配置
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_getOverseasAddressConfig{
	private static getOverseasAddressConfigBean bean;
	private static getOverseasAddressConfigCall call;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取商户是否支持海外地址配置");
	}

	@Before
	public void caseUp() {
		bean=new getOverseasAddressConfigBean();
		call=new getOverseasAddressConfigCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	private void check_verfiy() throws InterruptedException, JSONException
	{
		//config
		mch_configWapper configWapper=new mch_configWapper();
		mch_configExample example=new mch_configExample();
		example.createCriteria().andMchIdEqualTo(bean.getMchId());
		mch_config config=configWapper.selectByExample(example).get(0);
		Logger.verifyEquals("200", call.getStatusCode1(), "验证status");
		Logger.verifyEquals(bean.getMchId(), call.getMchId(), "验证MchId");
		Logger.verifyEquals(config.getOverseasAddressEnabled(), call.getOverseasAddressEnabled(), "验证OverseasAddressEnabled");
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getOverseasAddressConfig_001() {
		Logger.start(true,"获取商户是否支持海外地址配置-mchId是独立云版本主商户");
		try {
			createIndepMchBean createBean=GodmchManageCallService.InitCreateIndepMchBean();
			createIndepMchCall createCall=GodmchManageCallService.CreateIndepMchCall(createBean);
			
			bean.setMchId(createCall.getmchId());
			call.setData(bean);
			call.callService();	

			check_verfiy();
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getOverseasAddressConfig_002() {
		Logger.start(true,"获取商户是否支持海外地址配置-mchId是公共云版本海外渠道商");
		try {
			
			int userId_channl=GodmchManageCallService.CreateSellerMch();
			bean.setMchId(userId_channl);
			call.setData(bean);
			call.callService();			
			
			check_verfiy();
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getOverseasAddressConfig_003() {
		Logger.start(true,"获取商户是否支持海外地址配置-mchId为空");
		try {
			
			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("4001", call.getStatusCode1(), "验证status");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}